package com.hmkj.core.po.sysNotice;

import com.alibaba.fastjson.annotation.JSONField;
import com.hmkj.common.baseMapper.GenericPo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Table;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;


/**
 * 系统公告表实体信息<br>
 *
 * @author lizhijie
 * @date   2018-07-04 04:07:29
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "系统公告表")
@Table(name = "s_system_notice")
public class SystemNotice extends GenericPo<Integer> {

    public static final String TABLE_NAME = "s_system_notice";

	
	/**标题**/
	@ApiModelProperty(value = "标题")
	private String title;
	/**内容**/
	@ApiModelProperty(value = "内容")
	private Object content;
	/**发布人**/
	@ApiModelProperty(value = "发布人")
	private String publisher;
	/**发布时间**/
	@ApiModelProperty(value = "发布时间")
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
	private Date publishTime;
	/**发布状态：1未发布 ：2已发布**/
	@ApiModelProperty(value = "发布状态：1未发布 ：2已发布")
	private Integer status;
	/**备注**/
	@ApiModelProperty(value = "备注")
	private String remark;

	/**1,待发布:wait;2,已发布:published;3,已撤回:back**/
	public enum STATUS {

		/**1,待发布:wait**/
		WAIT("待发布",1),

		/**2,已发布:published**/
		PUBLISHED("已发布",2),

		/**3,已撤回:back**/
		BACK("已撤回",3);

		public final int code;
		public final String value;
		private static Map<Integer, String> map = new HashMap<Integer, String>();

		private STATUS(String value, int code) {
			this.code = code;
			this.value = value;
		}

		public static String getValue(Integer code) {
			if (null == code) {
				return null;
			}
			for (STATUS status : STATUS.values()) {
				if (status.code == code) {
					return status.value;
				}
			}
			return null;
		}

		public static Integer getCode(String value) {
			if (null == value  || "".equals(value)) {
				return null;
			}
			for (STATUS status : STATUS.values()) {
				if (status.value.equals(value)) {
					return status.code;
				}
			}
			return null;
		}

		public static  Map<Integer, String> getEnumMap() {
			if(map.size() == 0){
				for (STATUS status : STATUS.values()) {
					map.put(status.code,status.value);
				}
			}
			return map;
		}
	}
    public SystemNotice(){}

    public SystemNotice(Consumer<SystemNotice> consumer){
    consumer.accept(this);
    }
}

